﻿#pragma once


#include <QDialog>
#include <QPushButton>
#include "QListView"
#include "QStringListModel"
#include "QFileDialog"
#include "QMessageBox"
#include "QApplication"
#include "QVBoxLayout"
#include <QDesktopWidget>
#include <QLibrary>
#include <QApplication>
#include <QLabel>
#include <QComboBox>
#include "QListView"
#include "QStringListModel"
#include "QLineEdit"
#include "QSpinBox"
#include "QRadioButton"
#include <QSettings>

#include "commonfunction.h"

#include "halcon_opencv.h"

using namespace std;

#include "qt_graphics_view_image.h"
#include "qt_graphics_shape_rectangle.h"


class DetectionElectrodeRect :public QDialog
{
public:
    QSettings* m_qsettings;
    
    QString m_section   = "";

    MyQGraphicsView* m_view ;

   /* QLabel* m_qlabel_row1_offset;
    QSpinBox* m_qspinbox_row1_offset;

    QLabel* m_qlabel_row2_offset;
    QSpinBox* m_qspinbox_row2_offset;

    QLabel* m_qlabel_column1_offset;
    QSpinBox* m_qspinbox_column1_offset;

    QLabel* m_qlabel_column2_offset;
    QSpinBox* m_qspinbox_column2_offset;

    QLabel* m_qlabel_column21_offset;
    QSpinBox* m_qspinbox_column21_offset;

    QLabel* m_qlabel_column22_offset;
    QSpinBox* m_qspinbox_column22_offset;

    QLabel* m_qlabel_height_offset;
    QSpinBox* m_qspinbox_height_offset;*/



    QLabel* m_qlabel_eror_size_low;
    QSpinBox* m_qspinbox_error_size_low;

    QLabel* m_qlabel_eror_size_high;
    QSpinBox* m_qspinbox_eror_size_high;

    QLabel * m_qlabel_gray_threshold;
    QSpinBox * m_qspinbox_gray_threshold;
    QSlider* m_qslider_gray_threshold;
    
	QPushButton* m_pushbutton_show_orign_image;
    QPushButton* m_pushbutton_detection;
    QPushButton* m_pushbutton_save_parameter;
    QPushButton* m_pushbutton_return;

    QLabel* m_qlabel_message;

    int m_result;

	int row1, column1, row2, column2, area_defect_threshold, gray_defect_threshold;

    //int row1_offset, column1_offset, row2_offset, column2_offset, column21_offset, column22_offset, height_offset, area_unfilled_threshold, area_defect_threshold, gray_defect_threshold,, area_unfilled, gray_defect;
    int ret, message;


    HDevProcedure* m_proc_detection;
    HDevProcedureCall* m_call_detection;
    HObject  image_in, region_show;

    HObject  region_defect;

public:
    explicit DetectionElectrodeRect(QDialog *parent = nullptr, QSettings* qsettings = nullptr,QString section="") ;
    ~DetectionElectrodeRect() ;
    virtual void detectionImage();
    virtual bool detection( HObject image_in, QString& message);
    virtual void draw( Mat image_in,Mat& image_out);
    virtual void loadParameter();
    virtual void saveParameter();
    virtual bool showDialog();
   /* bool sendPLC(const Mat image_in,QString& message);
    void getRect(int x,int y,int width,int height);*/
    void testImage();
};
#pragma execution_character_set("utf-8")
